<template>
	<view class="nearbyBox">

		<view class="many">
			<text class="title">附近机构</text>
			<text @click="toClick">查看更多 </text>
		</view>
		<view>
			<scroll-view :scroll-x="true" style="white-space: nowrap;h228rpx">
				<template v-for="item in station" :key="item._id">
					<navigator :url="`/homepackge/pages/organizationalPage/organizationalPage?_id=${item._id}`"
						class="navigator-item">
						<view class="serviceBox">
							<view class="image-box">
								<image :src="item.image" style="width: 100%;height: 100%;background-size: cover;">
								</image>
							</view>
							<view class="stationName">
								<text>{{item.name}}</text>
								<text class="adress">据您3.6km</text>
							</view>
						</view>
					</navigator>
				</template>
			</scroll-view>
		</view>

	</view>
</template>

<script setup>
	import {
		onMounted,
		ref
	} from 'vue';
	import {
		getAllOrganizationApi
	} from '../../api/home';
	// import {
	// 	organizationsDetailApi
	// } from '../../api/nearbyLnstitutions';

	const station = ref([])
	onMounted(() => {
		accOrgan()
	})
	// 接受机构
	async function accOrgan() {
		const res = await getAllOrganizationApi()
		if (res.code == 200) {
			console.log(res);
			station.value = res.data.rows
		}
	}
	//点击附近机构跳转
	const toClick = () => {
		uni.navigateTo({
			url: '/homepackge/pages/nearbyLnstitutions/nearbyLnstitutions'
		})
	}
</script>

<style scoped lang="scss">
	.image-box {
		width: 160rpx;
		/* 你想要的显示宽度 */
		height: 160rpx;
		/* 你想要的高度 */
		overflow: hidden;
		/* 把超出的部分裁掉 */
	}

	.serviceBox {
		// display: flex;

		// justify-content: space-between;
		width: 492rpx;
		height: 228rpx;
		border: 1px solid #f0f0f0;
		// box-shadow:2px 2px 2px #f0f8ff;
		display: inline-block;
		margin-right: 30rpx;
		border-radius: 16px;
		margin-bottom: 40rpx;
		margin-top: 40rpx;
		position: relative;

		image {
			margin-top: 30rpx;
			margin-left: 30rpx;
		}
	}

	.stationName {
		position: absolute;
		top: 50rpx;
		right: 20rpx;
		display: inline-block;
		display: flex;
		flex-direction: column;
		flex-wrap: wrap;
		white-space: normal;
		width: 250rpx;
		height: 100%;

		text:first-child {
			font-size: 14px;
			color: #333;
		}

		.adress {
			font-size: 12px;
			color: #999;
			margin-top: 15rpx;
			// width: 150px;
		}
	}

	.nearbyBox {
		margin-top: 20rpx;
		padding: 0 40rpx;
		background: #fff;

		.title {
			margin-top: 40rpx;
			font-size: 19px;
		}

		.many {
			display: flex;
			justify-content: space-between;

			text:last-child {
				color: #999;
				font-size: 12px;
				margin-top: 50rpx;
			}

		}
	}
</style>